﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ScriptEditor.Commands
{
    class Command_ShowChar : Command
    {
        public string charName
        {
            get
            {
                return Value1;
            }
            set
            {
                Value1 = value;
            }
        }
        public string poseName
        {
            get
            {
                return Value2;
            }
            set
            {
                Value2 = value;
            }
        }
        public float duration
        {
            get
            {
                return float.TryParse(Value3, out float result) ? result : 0.5f;
            }
            set
            {
                Value3 = value.ToString();
            }
        }
        public Vector3 position
        {
            get
            {
                return StringToVector3(Value4);
            }
            set
            {
                Value4 = Vector3ToString(value);
            }
        }
        public Vector2 scale
        {
            get
            {
                return StringToVector2(Value5);
            }
            set
            {
                Value5 = Vector2ToString(value);
            }
        }
        public string transitionReF
        {
            get
            {
                return Value6;
            }
            set
            {
                Value6 = value;
            }
        }
        public float eye
        {
            get
            {
                string[] strs = Value7.Split(new char[] { '|' });
                return float.Parse(strs[0]);
            }
            set
            {
                string[] strs = Value7.Split(new char[] { '|' });
                Value7 = value.ToString() + "|" + strs[1] + "|" + strs[2];
            }
        }
        public float eyebrow
        {
            get
            {
                string[] strs = Value7.Split(new char[] { '|' });
                return float.Parse(strs[1]);
            }
            set
            {
                string[] strs = Value7.Split(new char[] { '|' });
                Value7 = strs[0] + "|" + value.ToString() + "|" + strs[2];
            }
        }
        public float mouth
        {
            get
            {
                string[] strs = Value7.Split(new char[] { '|' });
                return float.Parse(strs[2]);
            }
            set
            {
                string[] strs = Value7.Split(new char[] { '|' });
                Value7 = strs[0] + "|" + strs[1] + "|" + value.ToString();
            }
        }
        public float visibility
        {
            get
            {
                return float.TryParse(Value8, out float result) ? result : 1f;
            }
            set
            {
                Value8 = value.ToString();
            }
        }
        public Command_ShowChar()
        {
            CommandType = COMMANDTYPE.ShowChar;
            charName = "请输入角色名";
            poseName = "请输入姿势名";
            duration = 0.5f;
            position = new Vector3 { x = 0, y = 0, z = 0 };
            scale = new Vector2 { x = 1, y = 1 };
            transitionReF = "中心向四周";
            Value7 = "0|0|0";   //初始化结构避免出错
            visibility = 1;
            Wait = true;
        }
        public Command_ShowChar(string CharName, string PoseName, float Duration, Vector3 Position, Vector2 Scale, string TransitionReF, float Eye, float Eyebrow, float Mouth, float Visibility, bool waitForComplete)
        {
            CommandType = COMMANDTYPE.ShowChar;
            charName = CharName;
            poseName = PoseName;
            duration = Duration;
            position = Position;
            scale = Scale;
            transitionReF = TransitionReF;
            Value7 = "0|0|0";   //初始化结构避免出错
            eye = Eye;
            eyebrow = Eyebrow;
            mouth = Mouth;
            visibility = Visibility;
            Wait = waitForComplete;
        }
        public override string ToString()
        {
            return CommandType.ToString() + ":\n" + "显示人物:" + charName;
        }
    }
}
